package com.nulldev.util.image2.filters.color;

import java.awt.Color;
import java.awt.image.BufferedImage;

import com.nulldev.util.image2.ImageFilter;
import com.nulldev.util.java.utils.color.ColorUtil;

public class InvertImageFilter extends ImageFilter {

	@Override
	public BufferedImage process(final String command, final BufferedImage input) {
		final BufferedImage out = cloneCoreImage(input);
		for (int x = 0; x < input.getWidth(); x++) {
			for (int y = 0; y < input.getHeight(); y++) {
				final Color c = new Color(input.getRGB(x, y));
				final int rgb = ColorUtil.invertBAD(c).getRGB();
				out.setRGB(x, y, rgb);
				this.onProgress(x, y, x * y);
			}
		}
		return out;
	}

	@Override
	public void onProgress(int currentPosX, int currentPosY, int currentPixel) {
	}

}
